<script type="text/javascript">

processInputClick = function () {
	$(this).css("color", "#000");
	if ($(this).val() == $(this).attr("defValue")) $(this).val('');
}

processInputBlur = function () {
	var c = $(this).val(), v = $(this).attr("defValue");
	if ( !c || (c == v) ) 
		$(this).val(v).css("color", "#999");
}

checkForm = function() {
	
	xData.complete = 1;
	
	xData.inputs.each(function(){
		var e = $(this);
		var v = e.val(), d = e.attr("defValue");
		if ((v == '') || (v == d)) {
			xData.complete = 0;
			return false;
		}
		return true;
	});
	
	
	if (xData.complete)
		$(".feedbackform .submit").removeClass("g-button-disabled").css("opacity", "1").attr("title", "Отправить письмо");
	else
		$(".feedbackform .submit").addClass("g-button-disabled").css("opacity", "0.5").attr("title", "Необходимо заполнить все поля формы");
}

submitForm = function() {
	checkForm();
	if (xData.complete)
		$(".feedbackform").submit();
	return false;
}

showForm = function() {
	var f = $(".b_resume_form");
	if (f.css("display") != "block")
		f.show(200);
	return false;
}


jQuery(function($) {
	xData = {};	// data storage

	(xData.inputs = $(".feedbackform input").add(".feedbackform textarea").not(".submit")).css("color", "#888").click(processInputClick).focus(processInputClick).blur(processInputBlur).blur(checkForm).change(checkForm).keypress(checkForm);

	checkForm();
	
	$(".diags").fadeTo(5000, 0.01).slideUp(1000);

});

</script>
